package _12原子类AtomicInteger;

import java.util.concurrent.atomic.AtomicInteger;

public class Demo02 {
    static AtomicInteger x = new AtomicInteger();

    public static void main(String[] args) {

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100000; i++) {
                    x.incrementAndGet();
                }
                System.out.println("x = " + x);
            }
        }).start();

        new Thread(new Runnable() {
            @Override
            public void run() {
                for (int i = 0; i < 100000; i++) {
                    x.incrementAndGet();
                }
                System.out.println("x = " + x);
            }
        }).start();

    }
}
